package service.temp.job;


import io.reactivex.*;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RxJavaTest {

    public static void main(String[] args) throws InterruptedException {


//        val matchWithConfigResult = matchWithConfig(candidate)?.blockingGet()
//        System.out.println { "${candidate.vendorInventoryId} matchWithConfig result: $matchWithConfigResult" }
//        var output = matchWithConfigResult?.toMaybe() ?: containMatch(candidate)
//
        final Boolean aBoolean = runFirst().blockingGet();
        if (aBoolean) {
            runSecond();
        }

        System.out.println("tt main thread run.");

    }

    public static Maybe<Boolean> runFirst() {
        System.out.println("start to runFirst.");
        try {
            Thread.sleep(10000);
        } catch (Exception e) {
            System.out.println("runFirst got error!" + e);
        }

        System.out.println("end to runFirst.");
        return Maybe.just(true);
    }

    public static Maybe<Boolean> runSecond() {
        System.out.println("start to runSecond.");
        try {
            Thread.sleep(50);
        } catch (Exception e) {
            System.out.println("runFirst got error!" + e);
        }

        System.out.println("end to runSecond.");
        return Maybe.just(true);
    }


}
